import unittest, ddt

"""
ddt 使用步骤:
1. 在类上面添加装饰器:ddt.ddt
2. 在测试方法上面添加装饰器:ddt.data, ddt.unpack
"""
list1 = [[1, 2], [2, 2], [3, 2], [4, 2]]
list2 = [{"value1":1,"value2":2},{"value1":2,"value2":2},{"value1":3,"value2":2},{"value1":4,"value2":2}]

# 写一个测试类
@ddt.ddt
class MyTest(unittest.TestCase):
    # 列表传参
    # # @ddt.data([1,2])
    # # @ddt.data([1,2],[2,2],[3,2],[4,2])
    # @ddt.data(*list1)
    # @ddt.unpack
    # def test_bb1(self, value1, value2):
    #     print(f"\n====>value1:{value1},value2:{value2}")
    #     # 断言
    #     assert value1 == value2, "这两个数不相等"

    # 列表字典
    # @ddt.data({"value2":1,"value1":2})
    # @ddt.data({"value1":1,"value2":2},{"value1":2,"value2":2},{"value1":3,"value2":2},{"value1":4,"value2":2})
    @ddt.data(*list2)
    @ddt.unpack
    def test_bb1(self, value1, value2):
        print(f"\n====>value1:{value1},value2:{value2}")
        # 断言
        assert value1 == value2, "这两个数不相等"

if __name__ == '__main__':
    unittest.main(verbosity=2)
